﻿window.history.forward(1);//防止回退
function getStringCount(value)
{
    var bytesCount = 0;
    
//    for (var i = 0; i < value.length; i++)
//    {
//        var c = value.charAt(i);
//        if (/^[\u0000-\u00ff]$/.test(c))   //匹配双字节
//            bytesCount += 1;
//        else
//            bytesCount += 2;
//    }
    
    bytesCount = value.length;
    
    return bytesCount;
}
function containSpecialChar(value)
{
    var reg = new RegExp("[\`,\~,\!,\@,#,\$,\%,\^,\+,\*,\&,\\,\/,\?,\|,\:,\.,\<,\>,\{,\},\',\;,\=,\"]"); 
    
    return reg.test(value);
}
///显示弹出窗体
///Id:窗体ID TitleId：标题ID
function ShowPopForm(Id,TitleId,TitleMsg,boolShowMask)
{

//alert(boolShowMask);
  if (boolShowMask!="undefined") {
    showMask();
  }
  var obj=document.getElementById(Id);
  document.getElementById(TitleId).innerHTML=TitleMsg;
  document.getElementById(Id).style.display="block";
  obj.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-obj.offsetHeight)/2)+"px";
  obj.style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth/2-obj.offsetWidth/2)+"px";
}

///关闭弹出窗体
function ClosePopForm(Id,boolCosleMask)
{
 var obj=document.getElementById(Id);
 if(obj==null)
 {
   alert("objiect null!")
 }
  obj.style.display="none";
  if(boolCosleMask==null )
  {
    hideMask();
  }
  
  if(boolCosleMask)
  {
    hideMask();
  }
  
}

//显示遮罩
//  maskLayerId: 遮罩层id, 如为空则为默认值maskLayer
function showMask(maskLayerId)
{
    if(maskLayerId == null || maskLayerId.length < 1)
        maskLayerId = "maskLayer";
    var obj=document.getElementById(maskLayerId);
    if(obj!=null)
    {
        obj.style.display="block";
        return;
    }
 	$(document.body).prepend("<div id=\""+maskLayerId+"\"  class=\"layerMask\" style=\"position: absolute; left: 0px; top: 0px; z-index: 3; width: "+document.body.scrollWidth+"px; height: "+document.documentElement.scrollHeight+"px; \">  <iframe style=\"position: absolute; z-index: -1; width: 100%; height: 100%; display:block; top:0px;left: 0px; filter:Alpha(Opacity=0)\" scrolling=\"no\" frameborder=\"0\" ></div>"); 
  
}
//关闭遮罩
//  maskLayerId: 遮罩层id, 如为空则为默认值maskLayer
function hideMask(maskLayerId)
{
    if(maskLayerId == null || maskLayerId.length < 1)
        maskLayerId = "maskLayer";
        
  	var obj=document.getElementById(maskLayerId);
  	
  	if(obj!=null)
  	{
  	    obj.style.display="none";
  	}
  	
}






//显示提示框
var tid;

//callBack关闭回调
var closeCallBack; 
function showMassgeBox (title,msg,type,callBack,NoAutoHide)
{
	showMask("popupMask");//显示遮罩
	closeCallBack=callBack;
	
	var obj=document.getElementById("MassgeWindow");
	if(obj!=null)
	{
	  document.getElementById("Msg_Title").innerHTML=title;
	  document.getElementById("Msg_Content").innerHTML=msg;
	  switch(type)
	  {
	      case 1://提示
	        document.getElementById("Massge_Ioc").className="Message_Ioc_Notic";
	      break;
	      case 2://错误
	        document.getElementById("Massge_Ioc").className="Message_Ioc_Err";
	      break;
	      case 3://警告
	        document.getElementById("Massge_Ioc").className="Message_Ioc_Alert";
	      break;
	      case 4://提问
	        document.getElementById("Massge_Ioc").className="Message_Ioc_Question";
	      break;
	      default:
	       document.getElementById("Massge_Ioc").className="Message_Ioc_Notic";
	        
	 }
	  obj.style.display="block";
	  //调整位置
	  obj.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-obj.offsetHeight)/2)+"px";
      obj.style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth/2-obj.offsetWidth/2)+"px";
      tid=window.setTimeout("hideMassgeBox()",3000);
      return;
	}
	var html='<div class="layoutWarp" id="MassgeWindow" style="display:block;width:300px;z-index:20;">';
	html+='<div class="title">';
	html+='<span id="Msg_Title">'+title+'</span>';
	html+='<a title="关闭" href="javascript:hideMassgeBox()">关闭</a>';
	html+='</div>';
	html+='<table style="width:98%;height:100px;margin:5px ;" >';
	html+='<tr>';
	
	switch(type)
    {
      case 1://提示
        html+='<td id="Massge_Ioc"  style="width:40px;" class="Message_Ioc_Notic"></td>';
      break;
      case 2://错误
        html+='<td id="Massge_Ioc"  style="width:40px" class="Message_Ioc_Err"></td>';
      break;
      case 3://警告
        html+='<td id="Massge_Ioc"  style="width:40px" class="Message_Ioc_Alert"></td>';
      break;
      case 4://提问
        html+='<td id="Massge_Ioc"  style="width:40px" class="Message_Ioc_Question"></td>';
      break;
      default:
        html+='<td id="Massge_Ioc"  style="width:40px" class="Message_Ioc_Notic"></td>';
    }
	
	html+='<td id="Msg_Content" style="height:75px;text-align: left;"  >'+msg+'</td>';
	html+=' </tr>';
	html+='<tr>';
	html+=' <td  colspan="2" align="center" style="height:25px" ><input class="commonBut" name="" type="button" value="确定" onclick="hideMassgeBox()" /></td>';
	html+='</tr>';
	html+='</table>';
	html+='</div>';
	
	
	
//	<div class="layoutWarp">
//  <div class="title">
//    	<span>新增</span>
//        <a title="关闭" href="">关闭</a>
//    </div>
//    
//	<table class="layoutTable alertTable">
//      <tr>
//        <td>错误信息显示在这</td>
//      </tr>
//     
//      <tr>
//        <td><input class="commonBut" name="" type="button" value="修改" />&nbsp;&nbsp;<input class="commonBut" name="" type="button" value="修改" /></td>
//      </tr>
//    </table>

//</div>
	
	
	
    
  
    $(document.body).prepend(html);
    var obj1=document.getElementById("MassgeWindow");
	obj1.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-obj1.offsetHeight)/2)+"px";
    obj1.style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth/2-obj1.offsetWidth/2)+"px";
	
	if(NoAutoHide==null || !NoAutoHide)
	{
	    tid=window.setTimeout("hideMassgeBox()",3000);
	}
}
//关闭提示框

function hideMassgeBox()
{
	//$("#msgWindow").fadeOut("normal");
	var obj=document.getElementById("MassgeWindow");
	if(obj!=null)
	{
	    obj.style.display="none";
	}
	if(closeCallBack!=null)
	closeCallBack();
	hideMask("popupMask");
	if(tid!=null)
	{
	  window.clearTimeout(tid);
	}
}

//显示确认提示框
//title:标题
//msg:信息
//callback:确定回调
//cancelCallback:取消回调
var func;
var pama;
var func_cancel;

var boolClose=true;

function showConfirmBox(title,msg,callback,arg, cancelCallback)
{
    func=callback;
    pama=arg;
    func_cancel = cancelCallback;
    showMask();//显示遮罩
	var obj=document.getElementById("ConfirmWindow");
	if(obj!=null)
	{
	  document.getElementById("Confirm_Title").innerHTML=title;
	  document.getElementById("Confirm_Content").innerHTML=msg;
	  obj.style.display="block";
	  //调整位置
	  obj.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-obj.offsetHeight)/2)+"px";
      obj.style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth/2-obj.offsetWidth/2)+"px";
      return;
	}
	
	var html='<div class="layoutWarp" id="ConfirmWindow" style="z-index:1001;display:block;width:300px">';
	html+='<div class="title">';
	html+='<span id="Confirm_Title">'+title+'</span>';
	html+='<a title="关闭" href="javascript:cancelCallback()">关闭</a>';
	html+='</div>';
	html+='<table class="layoutTable alertTable">';
	html+='<tr>';
	
	html+='<td id="Confirm_Content">'+msg+'</td>';
	html+=' </tr>';
	html+='<tr>';
	html+=' <td align="center"><input class="commonBut" name="" type="button" value="确定" onclick="callback()" />&nbsp;&nbsp&nbsp;&nbsp<input class="commonBut" name="" type="button" value="取消" onclick="cancelCallback()" /></td>';
	html+='</tr>';
	html+='</table>';
	html+='</div>';
	
	
	
	
//    var html='<table width="299" height="117" border="0" id="ConfirmWindow" style="display:block">';
//    html+='<tr>';
//    html+='<td height="25" colspan="3" bgcolor="#CCCCCC" id="Confirm_Title">'+title+'</td>';
//    html+='</tr>';
//    html+='<tr>';
//    html+='<td width="234" colspan="3" bgcolor="#FFFFFF" id="Confirm_Content">'+msg+'</td>';
//    html+='</tr>';
//    html+='<tr>';
//    html+='<td height="25" colspan="3" align="center" valign="middle" bgcolor="#FFFFFF"><input type="button" name="button" id="button" value="确定" class="btnStyle" onclick="callback();" />&nbsp;&nbsp<input type="button" name="button" id="button" value="取消" class="btnStyle" onclick="cancelCallback();" /></td>';
//    html+='</tr>';
//    html+='</table>';	
    $(document.body).prepend(html);
    var obj1=document.getElementById("ConfirmWindow");
	obj1.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-obj1.offsetHeight)/2)+"px";
    obj1.style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth/2-obj1.offsetWidth/2)+"px";
}
//确认回调函数
function callback()
{
    closeConfirmBox();
    if(func!=null)
    {
        func(pama);
    }
}

//  取消按钮回调函数
function cancelCallback()
{
    closeConfirmBox();
    if(func_cancel!=null)
    {
        func_cancel(pama);
    }
}
//
function closeConfirmBox()
{
    var obj=document.getElementById("ConfirmWindow");
	if(obj!=null)
	{
	    obj.style.display="none";
	}
//	if(boolClose)
//	{
	
	    hideMask();
	//}
}






var obj; 
//关闭汽包

var timeId;
function hideNoticMsg() { 
 //var new_tr = id.parentNode;
 
 //document.getElementById("checkMsg") 
     $("#checkMsg").remove();
     if(timeId!=null)
     {
        clearTimeout(timeId);
     
     }
}
          
//显示汽包
//通过对象Id 
function showNoticMsg(id,msg,left,top) 
{   $("#checkMsg").remove(); 
    obj=document.getElementById(id);
    if(top==null) top=10;
    if(left==null) left=-100;
   /// <div class="bubble">sdfsdf</div>
   
   //<iframe style="position: absolute; z-index: -1; width: 100%; height: 100%; top: 0;left: 0; scrolling: no;" frameborder="0" src="about:blank">
    var str = '<div id="checkMsg" style="position:relative;display:inline;">';
    str+='<div class="bubble" style="padding-left:10px; padding-top:40px;position:absolute; left:'+left+'px; top:'+top+'px; z-index:10;">'+msg+'</div>';
    str+='<iframe style="position: absolute; z-index: -1; width: 240px; height: 78px; display:block; top:'+top+'px;left: '+left+'px; filter:Alpha(Opacity=0)" scrolling="no" frameborder="0" >';
    str+='</div>';
    insertHtml("afterend",obj,str); 
    //$('#checkMsg').bgiframe();
    timeId=window.setTimeout("hideNoticMsg()",1000);
}
//通过对象
function showNoticMsgByObj(obj,msg,left,top) 
{ 
    
    if(top==null) top=-10;
    if(left==null) left=0;
    var str = '<div id="checkMsg" style="position:relative;width:0px;height:0px">';
     str+='<div class="bubble" style="position:absolute; z-index:100000; left:'+left+'px; top:'+top+'px;">';
     str+='<div class="bubbleT"></div>	';
     str+='<div class="bubbleBody">'+msg+'</div><div class="bubbleB"></div></div></div>';
     
    var obj= insertHtml("afterend",obj,str); 
   
    // $("#checkMsg").fadeIn("slow"); 
     timeId=window.setTimeout("hideNoticMsg()",1000);
}
       
       
       ////////// 
 function insertHtml(where, el, html){ 
     where = where.toLowerCase();
	 if(el.nextSibling!=null)
	 {
	    // return;
	    
	    //alert(1);
	 	//el.parentNode.removeChild(el.nextSibling);
	 } 
     if(el.insertAdjacentHTML){ 
         switch(where){ 
             case "beforebegin": 
                 el.insertAdjacentHTML('beforeBegin', html); 
                 return el.previousSibling; 
             case "afterbegin": 
                 el.insertAdjacentHTML('afterBegin', html); 
                 return  el.firstChild; 
             case "beforeend": 
                 el.insertAdjacentHTML('beforeEnd', html); 
                 return  el.lastChild; 
             case "afterend": 
                 el.insertAdjacentHTML('afterEnd', html); 
                 return  el.nextSibling; 
         } 
       throw 'Illegal insertion point -> "' + where + '"'; 
     } 
	 var range = el.ownerDocument.createRange(); 
     var frag; 
     switch(where){ 
          case "beforebegin": 
             range.setStartBefore(el); 
            frag = range.createContextualFragment(html); 
             el.parentNode.insertBefore(frag, el); 
             return el.previousSibling; 
          case "afterbegin": 
             if(el.firstChild){ 
                 range.setStartBefore(el.firstChild); 
                frag = range.createContextualFragment(html); 
                 el.insertBefore(frag, el.firstChild); 
                 return el.firstChild; 
             }else{ 
                el.innerHTML = html; 
                 return el.firstChild; 
             } 
         case "beforeend": 
             if(el.lastChild){ 
                 range.setStartAfter(el.lastChild); 
                frag = range.createContextualFragment(html); 
                 el.appendChild(frag); 
                 return el.lastChild; 
             }else{ 
                el.innerHTML = html; 
                 return el.lastChild; 
             } 
         case "afterend": 
             range.setStartAfter(el); 
            frag = range.createContextualFragment(html); 
             el.parentNode.insertBefore(frag, el.nextSibling); 
             return el.nextSibling; 
         } 
         throw 'Illegal insertion point -> "' + where + '"'; 
		 
 } 
 
     
     //显示进度条

     function showLoading()
     {
        $(document.body).prepend("<div id=\"loading\" class=\"loading\" style=\"z-index: 100000\">信息加载中，请稍后...</div>");
     }

     function showLoadingImg(imgUrl)
     {
        $(document.body).prepend("<div id=\"loading\" class=\"loading\" style=\"z-index: 100000\"><img src=\""+imgUrl+"\"  style=\"width:32px; height:32px;\" /><span style=\"vertical-align: middle;\">信息加载中，请稍后...</span></div>");
     }
     //隐藏进度条

     function hideLoading()
     {
        $("#loading").remove();
     }
     
    
    
   ///String对象功能扩充 Trim/LTrim/RTrim(涂首豪)
   String.prototype.Trim = function()
   {
    return this.replace(/(^\s*)|(\s*$)/g, "");
   }

    String.prototype.LTrim = function()
    {
        return this.replace(/(^\s*)/g, "");
    }
    String.prototype.RTrim = function()
    {
       return this.replace(/(\s*$)/g, "");
    }






////////////////////////////////////////////////////////////

var HideElementTemp = new Array();
//点击菜单时，调用此的函数,菜单对象
function cal_hideElementAll(obj){ 
            cal_HideElement("IMG",obj);
            cal_HideElement("SELECT",obj);
            cal_HideElement("OBJECT",obj);
            cal_HideElement("IFRAME",obj);
}
function cal_HideElement(strElementTagName,obj){
try{
        var showDivElement = obj;
        var calendarDiv = obj;
        var intDivLeft = cal_GetOffsetLeft(showDivElement);
        var intDivTop = cal_GetOffsetTop(showDivElement);//+showDivElement.offsetHeight;
        //HideElementTemp=new Array()
        for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
var objTemp = window.document.all.tags(strElementTagName)[i];
if(!objTemp||!objTemp.offsetParent)
         continue;
var intObjLeft=cal_GetOffsetLeft(objTemp);
var intObjTop=cal_GetOffsetTop(objTemp);
if(((intObjLeft+objTemp.clientWidth)>intDivLeft)&&
        (intObjLeft<intDivLeft+calendarDiv.style.posWidth)&&
        (intObjTop+objTemp.clientHeight>intDivTop)&&
        (intObjTop<intDivTop+calendarDiv.style.posHeight)){
         //var intTempIndex=HideElementTemp.length;//已经有的长度
      //save elementTagName is stutas
         //HideElementTemp[intTempIndex]=new Array(objTemp,objTemp.style.visibility);
         HideElementTemp[HideElementTemp.length]=objTemp
         objTemp.style.visibility="hidden";
            }
        }
}catch(e){//alert(e.message)
}
}

function cal_ShowElement(){
        var i;
        for(i=0;i<HideElementTemp.length; i++){
var objTemp = HideElementTemp[i]
if(!objTemp||!objTemp.offsetParent)
         continue;
objTemp.style.visibility=''
        }
        HideElementTemp=new Array();
}
function cal_GetOffsetLeft(src){
        var set=0;
        if(src && src.name!="divMain"){
            if (src.offsetParent){
               set+=src.offsetLeft+cal_GetOffsetLeft(src.offsetParent);
}
if(src.tagName.toUpperCase()!="BODY"){
         var x=parseInt(src.scrollLeft,10);
         if(!isNaN(x))
                set-=x;
}
        }
        return set;
}

function cal_GetOffsetTop(src){
        var set=0;
        if(src && src.name!="divMain"){
            if (src.offsetParent){
                set+=src.offsetTop+cal_GetOffsetTop(src.offsetParent);
       }
if(src.tagName.toUpperCase()!="BODY"){
         var y=parseInt(src.scrollTop,10);
         if(!isNaN(y))
      set-=y;
}
        }
        return set;
}





///初始化窗口
$(document).ready(function(){

var o=$(".addLayer");
				
$.each( o , function(index,data){
data.style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight/2-data.offsetHeight/2-100)+"px";

}) 


$(document.body).resize(function(){alert(1)});

$(document.body).scroll( function() { 
				//alert(1);
			
				var o=$(".addLayer");
				
				 $.each( o , function(index,data){
				    data.style.top=(150+document.documentElement.scrollTop+document.documentElement.clientHeight/2-data.offsetHeight/2)+"px";
				 
				 }) 
				 } ); 
				 
				 
				 
				 
				 });
				 
window.onsize=function(){alert(1)}
/////////////////////////////////////////////////////////////////////////
     
//]]>





//////////

     
     
     
     
     